package com.simple.mapper;

import com.simple.dto.AmountDTO;
import com.simple.pojo.Amount;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface AmountMapper extends Mapper<Amount> {

    @Delete("<script> delete from tb_amount where id in " +
            "<foreach collection='ids' item='id' open='(' separator=',' close=')' >" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    void deleteByIds(@Param("ids") List<Integer> ids);

    @Select("select * from tb_amount where user_id = #{userId} order by create_time desc")
    List<Amount> getLatestAmountsByUserId(Integer userId);

    @Insert("insert into tb_amount (user_id,wx,zfb,wx_fund,zfb_fund,loan,create_time,create_user,update_time,update_user,remark) values " +
            "(#{userId},#{wx},#{zfb},#{wxFund},#{zfbFund},#{loan},#{createTime},#{createUser},#{updateTime},#{updateUser},#{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertAmount(Amount amount);

}